<?php 
App::import('Vendor','xtcpdf');  
$tcpdf = new XTCPDF();

// App::import('Vendor','tcpdf/tcpdf');
// $tcpdf = new TCPDF();

$textfont = 'freesans'; // looks better, finer, and more condensed than 'dejavusans'

$tcpdf->SetAuthor("SIDEP"); 
$tcpdf->SetAutoPageBreak( false ); 
$tcpdf->setHeaderFont(array($textfont,'',40));

// add a page (required with recent versions of tcpdf) 
$tcpdf->AddPage(); 

// Now you position and print your page content 
// example:  
$tcpdf->SetTextColor(0, 0, 0); 
$tcpdf->SetFont($textfont,'B', 16);
$tcpdf->Cell(0,14, 'RELATÓRIO ANALÍTICO DE DEPRECIAÇÃO DE BENS', 0,1,'C'); 
$tcpdf->SetFont($textfont,'B', 12);
$tcpdf->Cell(0,14, 'Conta: ' . $contaContabil['ContaContabil']['numero'].' - ' .$contaContabil['ContaContabil']['descricao'], 0,1,'L'); 

// //Column titles
// $header = array('Mês/Ano', 'Depreciação', 'Reavaliação', 'Redução', 'Depr. Acum.', 'V.Baixa Depr.', 'V. Liq. Cont.');

// //Data loading
// $data = $result;

// // print colored table
// $tcpdf->ColoredTable($header, $data);

$tbl = <<<EOD
			<table cellspacing="0" cellpadding="1" border="1">
			<thead>
			<tr>
				<th>Mês/Ano</th>
				<th>V. Aquis.</th>
				<th>V. Depr.</th>
				<th>V. Reaval.</th>
				<th>Redução</th>
				<th>Depr. Acum.</th>
				<th>V.Baixa Depr.</th>
				<th>V. Liq. Cont.</th>
			</tr>
			</thead>
			<tbody>
EOD;

foreach ($result as $row){
	$tbl .="<tr>";
	$tbl .="<td>{$row[0]['mes']} / {$row[0]['ano']}</td>";
	$tbl .="<td>".$row[0]['valor_aquisicao']."</td>";
	$tbl .="<td>".$row[0]['valor_depreciacao_mes']."</td>";
	$tbl .="<td>"."</td>";
	$tbl .="<td>"."</td>";
	$tbl .="<td>".$row[0]['valor_depreciacao_acumulada']."</td>";
	$tbl .="<td>"."</td>";
	$tbl .="<td>".$row[0]['valor_corrigido']."</td>";
	$tbl .="</tr>";
}

$tbl .="</tbody></table>";

$tcpdf->SetFont($textfont,'', 12);
$tcpdf->writeHTML($tbl, true, false, false, false, '');

// ... 
// etc. 
// see the TCPDF examples  

echo $tcpdf->Output('analitico_depreciacao.pdf', 'D'); 

?>